package ui;

import java.awt.BorderLayout;
import java.util.ArrayList;

import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

import controller.MobilePlanSellAndBillSystem;
import dto.LineBillDTO;

public class HistoricBillView  extends javax.swing.JFrame{
	private ArrayList<LineBillDTO> historicPerPeriod;
	private JTextArea jTextAreaBill;
	private JScrollPane srollPanel;
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				HistoricBillView inst = new HistoricBillView();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	public HistoricBillView(){
		super();
	}
	public void historicBillViewPerPeriod(ArrayList<LineBillDTO> historicPerPeriod) {
		this.historicPerPeriod=historicPerPeriod;
		initGUI();

	}
	private void initGUI(){
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jTextAreaBill = new JTextArea();
				srollPanel = new JScrollPane(jTextAreaBill); 
				//getContentPane().add(jTextAreaBill, BorderLayout.CENTER);
				getContentPane().add(srollPanel, BorderLayout.CENTER);
				
				 for (LineBillDTO bill:historicPerPeriod){
					 jTextAreaBill.append("-------------------Bill Start------------------\n");
						jTextAreaBill.append("Line Number: "+bill.getLineNumber()+"\n");
						jTextAreaBill.append("Total Cost: "+bill.getTotalCost()+"\n");
						jTextAreaBill.append("Client: "+bill.getUserName()+"\n");
					 jTextAreaBill.append("-------------------Details------------------\n");	
						jTextAreaBill.append(bill.getBillDetails()+"\n");
					 jTextAreaBill.append("-------------------Bill End------------------\n");
				 }
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
}
